
package shape;


import java.awt.geom.Point2D;


public class Rectangle extends GenericShape2D {

	protected double	base;
	protected double	height;


	public Rectangle() {
		super.position = new Point2D.Double(0, 0);
		this.base = 0;
		this.height = 0;
	}


	public Rectangle(Point2D position, double base, double height) {
		super.position.setLocation(position);
		this.base = base;
		this.height = height;
	}


	@Override
	public boolean contains(Point2D point) {
		return (Math.abs(point.getX() - (super.position.getX() - this.base / 2)) <= base
				+ DEFAULT_PRECISION
				&& Math.abs(point.getX()
						- (super.position.getX() + this.base / 2)) <= base
						- DEFAULT_PRECISION
				&& Math.abs(point.getY()
						- (super.position.getY() - this.height / 2)) <= height
						+ DEFAULT_PRECISION && Math.abs(point.getY()
				- (super.position.getY() + this.height / 2)) <= height
				- DEFAULT_PRECISION);
	}


	public double getBase() {
		return base;
	}


	public void setBase(double base) {
		this.base = base;
	}


	public double getHeight() {
		return height;
	}


	public void setHeight(double height) {
		this.height = height;
	}
}
